<template>
  <div>
    <a-radio-group :value="valueString" @change="change">
      <slot></slot>
    </a-radio-group>
    <a-button size="small" type="primary" @click="reset">重置</a-button>
  </div>
</template>

<script>
  //为来流程配置统一绑定数组格式
  export default {
    name: "RadioArray",
    props: {
      value: {
        type: Array
      }
    },
    watch: {
      value: {
        immediate: true,
        handler: function () {
          if (this.value) {
            this.valueString = this.value.join(',');
          } else {
            this.valueString = ''
          }
        }
      }
    },
    data() {
      return {
        valueString: ''
      }
    },
    methods: {
      change(e) {
        const value = e.target.value;
        this.$emit('input', value.split(','));
      },
      reset(){
        this.$emit('input',[]);
      }
    }

  }
</script>

<style scoped>

</style>